battman 2.2.1
battman.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2026 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
31// ----------------------------------------------------------------------------
32
33#ifndef BATTMAN_H
34#define BATTMAN_H
35
40#ifdef PREINIT_SUPPORTED
41#include "preinit.h"
42#endif
43
44#ifdef MikroCCoreVersion
45 #if MikroCCoreVersion >= 1
46 #include "delays.h"
47 #endif
48#endif
49
50#include "drv_digital_out.h"
51#include "drv_digital_in.h"
52
53// -------------------------------------------------------------- PUBLIC MACROS
58
63#define BATTMAN_MAP_MIKROBUS( cfg, mikrobus ) \
64 cfg.chg = MIKROBUS( mikrobus, MIKROBUS_AN ); \
65 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
66 cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
67
68
73#define BATTMAN_RETVAL uint8_t
74
75#define BATTMAN_OK 0x00
76#define BATTMAN_INIT_ERROR 0xFF
78 // End group macro
80// --------------------------------------------------------------- PUBLIC TYPES
85
89typedef struct
90{
91 // Output pins
92
93 digital_out_t en;
94
95 // Input pins
96
97 digital_in_t chg;
98 digital_in_t flt;
99
100} battman_t;
101
105typedef struct
106{
107 // Additional gpio pins
108
109 pin_name_t chg;
110 pin_name_t en;
111 pin_name_t flt;
112
114 // End types group
116// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
117
122
123#ifdef __cplusplus
124extern "C"{
125#endif
126
136
146
155void battman_set_enable ( battman_t *ctx, uint8_t state );
156
167
178
179
180#ifdef __cplusplus
181}
182#endif
183#endif // _BATTMAN_H_
184 // End public_function group
187
188// ------------------------------------------------------------------------- END
#define BATTMAN_RETVAL
Definition battman.h:73
void battman_set_enable(battman_t *ctx, uint8_t state)
Enable/Disable control.
uint8_t battman_get_fault_indicator(battman_t *ctx)
Fault indicator status.
uint8_t battman_get_charging_indicator(battman_t *ctx)
Charging indicator status.
void battman_cfg_setup(battman_cfg_t *cfg)
Config Object Initialization function.
BATTMAN_RETVAL battman_init(battman_t *ctx, battman_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition battman.h:106
pin_name_t flt
Definition battman.h:111
pin_name_t en
Definition battman.h:110
pin_name_t chg
Definition battman.h:109
Click ctx object definition.
Definition battman.h:90
digital_in_t flt
Definition battman.h:98
digital_in_t chg
Definition battman.h:97
digital_out_t en
Definition battman.h:93